package com.han.swagger2markdown.core.project;

import com.han.swagger2markdown.core.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

@Api("项目接口")
@RestController
@RequestMapping("/projects")
public class ProjectController {

    @ApiOperation("创建项目")
    @PostMapping()
    public Result<Project> create(@RequestBody ProjectCreateParam createParam) {
        return Result.success(new Project());
    }

    @ApiOperation("批量创建项目")
    @PostMapping("/batch")
    public Result<List<Project>> batchCreate(@RequestBody List<ProjectCreateParam> createParams) {
        return Result.success(new ArrayList<>());
    }

    @ApiOperation("查询项目列表")
    @GetMapping("/list")
    public Result<List<Project>> list(@ApiParam("模糊查询") @RequestParam(required = false) String name,
                                      @ApiParam(value = "类型", allowableValues = "standard, custom") @RequestParam(required = false) String type) {
        return Result.success(new ArrayList<>());
    }

    @ApiOperation("查询项目 by id")
    @GetMapping("/{id}")
    public Result<Project> queryByOid(@PathVariable Integer id) {
        return Result.success(new Project());
    }

    @ApiOperation("更新项目 by id")
    @PutMapping("/{id}")
    public Result<Project> updateByOid(@PathVariable Integer id, @RequestBody ProjectUpdateParam updateParam) {
        return Result.success(new Project());
    }

    @ApiOperation("删除项目")
    @DeleteMapping("/{id}")
    public Result<Void> deleteByOid(@PathVariable Integer id) {
        return Result.success();
    }

    @ApiOperation("批量删除项目")
    @DeleteMapping("/batch")
    public Result<Void> batchDeleteByOids(@RequestBody List<String> oids) {
        return Result.success();
    }
}
